package net.example.model;

import java.util.ArrayList;
import java.util.List;

/**
 * 好友分组容器。
 */
public class FriendCatalogContainer {
    String catalogName;
    List<GGUser> friendList;

    public FriendCatalogContainer() {
        catalogName = "";
        friendList = new ArrayList<GGUser>();
    }

    public FriendCatalogContainer(String groupName, List<GGUser> groupChild) {
        this.catalogName = groupName;
        this.friendList = new ArrayList<GGUser>();
        for (int i = 0; i < groupChild.size(); i++)
            friendList.add(groupChild.get(i));
    }

    public void add(GGUser GGUser) {// 往小组中添加用户
        if(this.friendList.contains(GGUser))
        {
            return;
        }
        friendList.add(GGUser);
    }

    public void add(int index, GGUser GGUser)
    {
        this.friendList.remove(GGUser);
        this.friendList.add(index, GGUser);
    }

    public void remove(GGUser u) {// 根据用户对象移除用户
        friendList.remove(u);
    }

    public void remove(int index) {// 根据下标移除用户
        friendList.remove(index);
    }

    public int getChildSize() {// 小组的大小
        return friendList.size();
    }

    public GGUser getChild(int index) {// 根据下标得到用户
        return friendList.get(index);
    }

    public String getgroupName() {
        return catalogName;
    }

    public void setgroupName(String m_groupName) {
        this.catalogName = m_groupName;
    }

    public List<GGUser> getGroupChild() {
        return friendList;
    }

    public void setGroupChild(List<GGUser> groupChild) {
        this.friendList = groupChild;
    }
}
